﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ETA.Web.Controllers
{
    public class LocalizationController : Controller
    {
        public ActionResult ChangeCulture(string cultureName, string returnUrl = "")
        {
            Response.Cookies.Add(new HttpCookie("Localization.CultureName", cultureName) { Expires = DateTime.Now.AddYears(2) });

            if (Request.IsAjaxRequest())
            {
                return Json(new Response { Result = new Dtos.ResultDto { IsSuccess = true } }, JsonRequestBehavior.AllowGet);
            }

            if (!string.IsNullOrWhiteSpace(returnUrl))
            {
                return Redirect(returnUrl);
            }

            return Redirect("/");
        }

    }
}
